package service

import (
	"Graphite/database"
	"Graphite/model"
	"Graphite/util"
	"context"
	"fmt"
	"github.com/gin-gonic/gin"
	"go.mongodb.org/mongo-driver/bson"
	"go.mongodb.org/mongo-driver/bson/primitive"
	"go.mongodb.org/mongo-driver/mongo/options"
	"io"
	"log"
	"mime/multipart"
	"os"
	"strconv"
	"strings"
)
type Data struct {
	UpdateAmount interface{}
	UpdateWeight interface{}
}
type Case2 struct {
	Id                primitive.ObjectID `bson:"_id,omitempty" json:"_id" form:"_id"`
	Norms             string             `bson:"norms" form:"norms" json:"norms"`
	Amount            int                `bson:"amount" json:"amount" form:"amount"`
	Type              string             `bson:"type" json:"type" form:"type"`
	Desc              string             `bson:"desc" json:"desc" form:"desc"`
	Weight_Before     float32            `bson:"weight_before" json:"weight_before" form:"weight_before"`
	Weight_after      float32            `bson:"weight_after" json:"weight_after" form:"weight_after"`
	WGR               float32            `bson:"WGR" form:"WGR" json:"WGR"`
	OutLetTemperature float32            `json:"outletTemperature" bson:"outletTemperature" form:"outletTemperature"`
	InLetTemperature  float32            `json:"inletTemperature" bson:"inletTemperature" form:"inletTemperature"`
} //通过updateDipNote2方法调用判断结构体是否为空(比较方法)
//配置表
func UpdateCon(pz model.PeiZhi, col string) interface{} {
	db := database.GetMongoDB()
	collection := db.Collection(col)
	_, err := collection.UpdateOne(context.Background(), bson.M{"_id": pz.Id}, bson.M{"$set": pz})
	if err != nil {
		fmt.Println(err)
	}
	result := util.Result(pz.Id, col)
	return result
}

//浸渍
//浸渍小时数据
func UpdateHour(dhd model.DippingHourData, col string) interface{} {
	db := database.GetMongoDB()
	collection := db.Collection(col)
	_, err := collection.UpdateOne(context.Background(), bson.M{"_id": dhd.Id}, bson.M{"$set": dhd})
	if err != nil {
		fmt.Println(err)
	}
	result := util.Result(dhd.Id, col)
	return result
}

//天然气用量
func UpdateGas(usage model.NaturalGasUsage, col string) interface{} {
	db := database.GetMongoDB()
	collection := db.Collection(col)
	_, err := collection.UpdateOne(context.Background(), bson.M{"_id": usage.Id}, bson.M{"$set": usage})
	if err != nil {
		fmt.Println(err)
	}
	result := util.Result(usage.Id, col)
	return result
}

//浸渍系统运行记录
func UpdateDipNote(dsn model.DippingSystemNote2, col string) interface{} {
	db := database.GetMongoDB()
	collection := db.Collection(col)
	_, err := collection.UpdateOne(context.Background(), bson.M{"_id": dsn.Id}, bson.M{"$set": dsn})
	if err != nil {
		fmt.Println(err)
	}
	result := util.Result(dsn.Id, col)
	return result
}

//特殊修改浸渍表Case结构体数组
func UpdateDipNote2(dsn model.DippingSystemNote, col string) interface{} {
	db := database.GetMongoDB()
	collection := db.Collection(col)
	var num int
	var a Case2 //定义结构体判空
	for i, Case := range dsn.Case {
		if Case != a { //判断非空 获取数组下标
			fmt.Println("i:-----", i)
			num = i
		} else {
			fmt.Println("result:----nil")
		}
	}
	filter := bson.M{"_id": dsn.Id}                     //修改条件
	update := bson.M{"case.$[item]": dsn.Case[num]}     //修改内容
	arrayFilter := bson.M{"item._id": dsn.Case[num].Id} //获取数据里数组下元素
	var updateOptions *options.UpdateOptions
	updateOptions = &options.UpdateOptions{}
	updateOptions.SetArrayFilters(
		options.ArrayFilters{
			Filters: []interface{}{
				arrayFilter,
			},
		},
	)
	_, err := collection.UpdateOne(context.Background(), filter, bson.M{"$set": update}, updateOptions)
	if err != nil {
		fmt.Println("err:", err)
	}
	result := util.Result(dsn.Id, col)
	return result
}

//石墨化
//质量要求
func UpdateQua(qr model.QualityRequired, col string) interface{} {
	db := database.GetMongoDB()
	collection := db.Collection(col)
	_, err := collection.UpdateOne(context.Background(), bson.M{"_id": qr.Id}, bson.M{"$set": qr})
	if err != nil {
		fmt.Println(err)
	}
	result := util.Result(qr.Id, col)
	return result
}

//装炉报告
func UpdateLoad(lo model.LoadOven, col string) interface{} {
	db := database.GetMongoDB()
	collection := db.Collection(col)
	_, err := collection.UpdateOne(context.Background(), bson.M{"_id": lo.Id}, bson.M{"$set": lo})
	if err != nil {
		fmt.Println(err)
	}
	result := util.Result(lo.Id, col)
	return result
}

//修改送电曲线
func UpdateEle(elc model.ElectricityCurve, col string) interface{} {
	db := database.GetMongoDB()
	collection := db.Collection(col)
	_, err := collection.UpdateOne(context.Background(), bson.M{"_id": elc.Id}, bson.M{"$set": elc})
	if err != nil {
		fmt.Println(err)
	}
	result := util.Result(elc.Id, col)
	return result
}

//修改基本信息
func UpdateBasic(bi model.BasicInformation, col string) interface{} {
	db := database.GetMongoDB()
	collection := db.Collection(col)
	_, err := collection.UpdateOne(context.Background(), bson.M{"_id": bi.Id}, bson.M{"$set": bi})
	if err != nil {
		fmt.Println(err)
	}
	result := util.Result(bi.Id, col)
	return result
}

//修改详细信息
func UpdateDetail(de model.DetailedInformation, col string) interface{} {
	db := database.GetMongoDB()
	collection := db.Collection(col)
	_, err := collection.UpdateOne(context.Background(), bson.M{"_id": de.Id}, bson.M{"$set": de})
	if err != nil {
		fmt.Println(err)
	}
	result := util.Result(de.Id, col)
	return result
}

//成型1
//筛分记录
func UpdateScr(sr model.ScreeningRecord, col string) interface{} {
	db := database.GetMongoDB()
	collection := db.Collection(col)
	_, err := collection.UpdateOne(context.Background(), bson.M{"_id": sr.Id}, bson.M{"$set": sr})
	if err != nil {
		fmt.Println(err)
	}
	result := util.Result(sr.Id, col)
	return result
}

//成型2
//配料记录
func UpdateIngred(ir model.IngredientRecord, col string) interface{} {
	db := database.GetMongoDB()
	collection := db.Collection(col)
	_, err := collection.UpdateOne(context.Background(), bson.M{"_id": ir.Id}, bson.M{"$set": ir})
	if err != nil {
		fmt.Println(err)
	}
	result := util.Result(ir.Id, col)
	return result
}

//库管
//原始记录
func UpdateInit(init model.InitRecord, col string) interface{} {
	db := database.GetMongoDB()
	collection := db.Collection(col)
	_, err := collection.UpdateOne(context.Background(), bson.M{"_id": init.Id}, bson.M{"$set": init})
	if err != nil {
		fmt.Println(err)
	}
	result := util.Result(init.Id, col)
	return result
}

//质检
//检查日报
func UpdateDaily(dr model.DailyReport, col string) interface{} {
	db := database.GetMongoDB()
	collection := db.Collection(col)
	_, err := collection.UpdateOne(context.Background(), bson.M{"_id": dr.Id}, bson.M{"$set": dr})
	if err != nil {
		fmt.Println(err)
	}
	result := util.Result(dr.Id, col)
	return result
}

//产品
//修改产品信息
func UpdatePro(pro model.Production, col string) interface{} {
	db := database.GetMongoDB()
	collection := db.Collection(col)
	_, err := collection.UpdateOne(context.Background(), bson.M{"_id": pro.Id}, bson.M{"$set": pro})
	if err != nil {
		fmt.Println(err)
	}
	result := util.Result(pro.Id, col)
	return result
}

//隧道窑
//测点信息
func UpdateLoc(loc model.LocationInfo, col string) interface{} {
	db := database.GetMongoDB()
	collection := db.Collection(col)
	_, err := collection.UpdateOne(context.Background(), bson.M{"_id": loc.Id}, bson.M{"$set": loc})
	if err != nil {
		fmt.Println(err)
	}
	result := util.Result(loc.Id, col)
	return result
}

//进车信息
func UpdateIncar(in model.Incar_Info, col string) interface{} {
	db := database.GetMongoDB()
	collection := db.Collection(col)
	_, err := collection.UpdateOne(context.Background(), bson.M{"_id": in.Id}, bson.M{"$set": in})
	if err != nil {
		fmt.Println(err)
	}
	result := util.Result(in.Id, col)
	return result
}

//出车信息
func UpdateOutcar(out model.Outcar_Info, col string) interface{} {
	db := database.GetMongoDB()
	collection := db.Collection(col)
	_, err := collection.UpdateOne(context.Background(), bson.M{"_id": out.Id}, bson.M{"$set": out})
	if err != nil {
		fmt.Println(err)
	}
	result := util.Result(out.Id, col)
	return result
}

//交接班
func UpdateHan_Suc(hs model.Handover_Successor, col string) interface{} {
	db := database.GetMongoDB()
	collection := db.Collection(col)
	_, err := collection.UpdateOne(context.Background(), bson.M{"_id": hs.Id}, bson.M{"$set": hs})
	if err != nil {
		fmt.Println(err)
	}
	result := util.Result(hs.Id, col)
	return result
}
//数量表
func UpdateGoods(c *gin.Context,num model.Amount, col string) Data {
	db := database.GetMongoDB()
	collection := db.Collection(col)
	_, err := collection.UpdateOne(context.Background(), bson.M{"_id": num.Id}, bson.M{"$set": num})
	if err != nil {
		fmt.Println(err)
	}
	var result Data
	result.UpdateAmount = util.ResultAmount(num.Id, col)
	switch num.Diameter {
	case "Φ600":
		data2 := UpdateWeight600(c,num,"weight")
		result.UpdateWeight=data2
	case "Φ550":
		data2 := UpdateWeight550(c,num,"weight")
		result.UpdateWeight=data2
	case "Φ500":
		data2 := UpdateWeight500(c,num,"weight")
		result.UpdateWeight=data2
	case "Φ450":
		data2 := UpdateWeight450(c,num,"weight")
		result.UpdateWeight=data2
	case "Φ400":
		data2 := UpdateWeight400(c,num,"weight")
		result.UpdateWeight=data2
	case "Φ350":
		data2 := UpdateWeight350(c,num,"weight")
		result.UpdateWeight=data2
	case "Φ300":
		data2 := UpdateWeight300(c,num,"weight")
		result.UpdateWeight=data2
	case "Φ250":
		data2 := UpdateWeight250(c,num,"weight")
		result.UpdateWeight=data2
	case "Φ200":
		data2 := UpdateWeight200(c,num,"weight")
		result.UpdateWeight=data2
	case "Φ234":
		data2 := UpdateWeight234(c,num,"weight")
		result.UpdateWeight=data2
	case "Φ256":
		data2 := UpdateWeight256(c,num,"weight")
		result.UpdateWeight=data2
	case "Φ288":
		data2 := UpdateWeight288(c,num,"weight")
		result.UpdateWeight=data2
	case "Φ315":
		data2 := UpdateWeight315(c,num,"weight")
		result.UpdateWeight=data2
	case "Φ333":
		data2 := UpdateWeight333(c,num,"weight")
		result.UpdateWeight=data2
	case "次品":
		data2 := UpdateLow(c,num,"weight")
		result.UpdateWeight=data2
	}
	return result
}
//修改重量表
func UpdateWeight600(c *gin.Context,num model.Amount,col string) interface{}{
	db := database.GetMongoDB()
	collection := db.Collection(col)
	var wei model.Weight
	wei.Diameter = num.Diameter
	wei.Desc = num.Desc
	wei.Process_Length = num.Process_Length
	wei.Time_Stamp = num.Time_Stamp
	switch num.Process_Length {
	case "RP-1950":
		wei.Finish_Product, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", 0.85*float64(num.Finish_Product)), 64)
		wei.RoughCast, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.965*float64(num.RoughCast)), 64)
		wei.Graphitization_Furnace, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.992*float64(num.Graphitization_Furnace)), 64)
		wei.Second_Burn = float64(num.Second_Burn)
		wei.Second_Burn_Furnace = float64(num.Second_Burn_Furnace)
		wei.Once_Dip = float64(num.Once_Dip)
		wei.Once_Burn, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.992*float64(num.Once_Burn)), 64)
		wei.Once_Burn_Furnace, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 1.083*float64(num.Once_Burn_Furnace)), 64)
		wei.Green_Body, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 1.083*float64(num.Green_Body)), 64)
	case "RP-2250":
		wei.Finish_Product, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", 0.95*float64(num.Finish_Product)), 64)
		wei.RoughCast, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", 1.11*float64(num.RoughCast)), 64)
		wei.Graphitization_Furnace, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 1.144*float64(num.Graphitization_Furnace)), 64)
		wei.Second_Burn = float64(num.Second_Burn)
		wei.Second_Burn_Furnace = float64(num.Second_Burn_Furnace)
		wei.Once_Dip = float64(num.Once_Dip)
		wei.Once_Burn, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 1.144*float64(num.Once_Burn)), 64)
		wei.Once_Burn_Furnace, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 1.229*float64(num.Once_Burn_Furnace)), 64)
		wei.Green_Body, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 1.229*float64(num.Green_Body)), 64)
	case "IP-1950":
		wei.Finish_Product, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", 0.9*float64(num.Finish_Product)), 64)
		wei.RoughCast, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 1.103*float64(num.RoughCast)), 64)
		wei.Graphitization_Furnace, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 1.063*float64(num.Graphitization_Furnace)), 64)
		wei.Second_Burn, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 1.063*float64(num.Second_Burn)), 64)
		wei.Second_Burn_Furnace, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 1.147*float64(num.Second_Burn_Furnace)), 64)
		wei.Once_Dip, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 1.147*float64(num.Once_Dip)), 64)
		wei.Once_Burn, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.992*float64(num.Once_Burn)), 64)
		wei.Once_Burn_Furnace, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 1.083*float64(num.Once_Burn_Furnace)), 64)
		wei.Green_Body, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 1.083*float64(num.Green_Body)), 64)
	case "IP-2250":
		wei.Finish_Product, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", 1.02*float64(num.Finish_Product)), 64)
		wei.RoughCast, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 1.167*float64(num.RoughCast)), 64)
		wei.Graphitization_Furnace, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 1.225*float64(num.Graphitization_Furnace)), 64)
		wei.Second_Burn, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 1.225*float64(num.Second_Burn)), 64)
		wei.Second_Burn_Furnace, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 1.322*float64(num.Second_Burn_Furnace)), 64)
		wei.Once_Dip, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 1.322*float64(num.Once_Dip)), 64)
		wei.Once_Burn, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 1.144*float64(num.Once_Burn)), 64)
		wei.Once_Burn_Furnace, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 1.229*float64(num.Once_Burn_Furnace)), 64)
		wei.Green_Body, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 1.229*float64(num.Green_Body)), 64)
	}
	_,err := collection.UpdateOne(context.Background(), bson.M{"time_stamp":wei.Time_Stamp},bson.M{"$set": wei})
	if err != nil {
		fmt.Println(err)
	}

	//同步汇总表
	parts := strings.SplitN(wei.Process_Length, "-", 2)
	var cargo model.CargoSummary
	var tmp = wei.Diameter + parts[0]
	CargoSummary := db.Collection("CargoSummary")
	err = CargoSummary.FindOne(context.Background(), bson.M{"process_specifications": tmp}).Decode(&cargo)
	if err!= nil {
		log.Println(err)
	} else {
		cargo.Finish_Product,_ = strconv.ParseFloat(fmt.Sprintf("%.1f",wei.Finish_Product ), 64)
		cargo.RoughCast,_ = strconv.ParseFloat(fmt.Sprintf("%.1f",wei.RoughCast ), 64)
		cargo.Second_Burn,_ = strconv.ParseFloat(fmt.Sprintf("%.1f",wei.Second_Burn + wei.Second_Burn_Furnace ), 64)
		cargo.Once_Dip,_ =strconv.ParseFloat(fmt.Sprintf("%.1f",wei.Once_Dip ), 64)
		cargo.Once_Burn,_ = strconv.ParseFloat(fmt.Sprintf("%.1f",wei.Once_Burn), 64)
		cargo.Green_Body,_ = strconv.ParseFloat(fmt.Sprintf("%.1f", wei.Once_Burn_Furnace + wei.Green_Body), 64)
		cargo.Time_Stamp = wei.Time_Stamp
		cargo.Diameter = wei.Diameter

		util.UpdateOne1(c,"CargoSummary",cargo,"_id",cargo.Id)
	}

	return wei
}
//直径550
func UpdateWeight550(c *gin.Context,num model.Amount,col string) interface{}{
	db := database.GetMongoDB()
	collection := db.Collection(col)
	var wei model.Weight
	wei.Diameter = num.Diameter
	wei.Desc = num.Desc
	wei.Process_Length = num.Process_Length
	wei.Time_Stamp = num.Time_Stamp
	//公式部分
	wei.Finish_Product, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.876*float64(num.Finish_Product)), 64)
	wei.RoughCast, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.976*float64(num.RoughCast)), 64)
	wei.Graphitization_Furnace, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 1.005*float64(num.Graphitization_Furnace)), 64)
	wei.Second_Burn, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 1.005*float64(num.Second_Burn)), 64)
	wei.Second_Burn_Furnace, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 1.087*float64(num.Second_Burn_Furnace)), 64)
	wei.Once_Dip, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 1.087*float64(num.Once_Dip)), 64)
	wei.Once_Burn, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.943*float64(num.Once_Burn)), 64)
	wei.Once_Burn_Furnace, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 1.022*float64(num.Once_Burn_Furnace)), 64)
	wei.Green_Body, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 1.022*float64(num.Green_Body)), 64)
	_,err := collection.UpdateOne(context.Background(), bson.M{"time_stamp":wei.Time_Stamp},bson.M{"$set": wei})
	if err != nil {
		fmt.Println(err)
	}

	//同步汇总表
	parts := strings.SplitN(wei.Process_Length, "-", 2)
	var cargo model.CargoSummary
	var tmp = wei.Diameter + parts[0]
	CargoSummary := db.Collection("CargoSummary")
	err = CargoSummary.FindOne(context.Background(), bson.M{"process_specifications": tmp}).Decode(&cargo)
	if err!= nil {
		log.Println(err)
	} else {
		cargo.Finish_Product,_ = strconv.ParseFloat(fmt.Sprintf("%.1f",wei.Finish_Product ), 64)
		cargo.RoughCast,_ = strconv.ParseFloat(fmt.Sprintf("%.1f",wei.RoughCast ), 64)
		cargo.Second_Burn,_ = strconv.ParseFloat(fmt.Sprintf("%.1f",wei.Second_Burn + wei.Second_Burn_Furnace ), 64)
		cargo.Once_Dip,_ =strconv.ParseFloat(fmt.Sprintf("%.1f",wei.Once_Dip ), 64)
		cargo.Once_Burn,_ = strconv.ParseFloat(fmt.Sprintf("%.1f",wei.Once_Burn), 64)
		cargo.Green_Body,_ = strconv.ParseFloat(fmt.Sprintf("%.1f", wei.Once_Burn_Furnace + wei.Green_Body), 64)
		cargo.Time_Stamp = wei.Time_Stamp
		cargo.Diameter = wei.Diameter

		util.UpdateOne1(c,"CargoSummary",cargo,"_id",cargo.Id)
	}
	return wei
}
//直径500
func UpdateWeight500(c *gin.Context,num model.Amount,col string) interface{}{
	db := database.GetMongoDB()
	collection := db.Collection(col)
	var wei model.Weight
	wei.Diameter = num.Diameter
	wei.Desc = num.Desc
	wei.Process_Length = num.Process_Length
	wei.Time_Stamp = num.Time_Stamp
	switch num.Process_Length {
	case "RP-1950":
		wei.Finish_Product, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", 0.56*float64(num.Finish_Product)), 64)
		wei.RoughCast, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.668*float64(num.RoughCast)), 64)
		wei.Graphitization_Furnace, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.682*float64(num.Graphitization_Furnace)), 64)
		wei.Second_Burn = float64(num.Second_Burn)
		wei.Second_Burn_Furnace = float64(num.Second_Burn_Furnace)
		wei.Once_Dip = float64(num.Once_Dip)
		wei.Once_Burn, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", 0.682*float64(num.Once_Burn)), 64)
		wei.Once_Burn_Furnace, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.738*float64(num.Once_Burn_Furnace)), 64)
		wei.Green_Body, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.738*float64(num.Green_Body)), 64)
	case "RP-2250":
		wei.Finish_Product, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", 0.64*float64(num.Finish_Product)), 64)
		wei.RoughCast, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.753*float64(num.RoughCast)), 64)
		wei.Graphitization_Furnace, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", 0.78*float64(num.Graphitization_Furnace)), 64)
		wei.Second_Burn = float64(num.Second_Burn)
		wei.Second_Burn_Furnace = float64(num.Second_Burn_Furnace)
		wei.Once_Dip = float64(num.Once_Dip)
		wei.Once_Burn, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", 0.78*float64(num.Once_Burn)), 64)
		wei.Once_Burn_Furnace, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.845*float64(num.Once_Burn_Furnace)), 64)
		wei.Green_Body, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.845*float64(num.Green_Body)), 64)
	case "IP-1950":
		wei.Finish_Product, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", 0.6*float64(num.Finish_Product)), 64)
		wei.RoughCast, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.717*float64(num.RoughCast)), 64)
		wei.Graphitization_Furnace, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", 0.74*float64(num.Graphitization_Furnace)), 64)
		wei.Second_Burn, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", 0.74*float64(num.Second_Burn)), 64)
		wei.Second_Burn_Furnace, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.814*float64(num.Second_Burn_Furnace)), 64)
		wei.Once_Dip, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.814*float64(num.Once_Dip)), 64)
		wei.Once_Burn, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.682*float64(num.Once_Burn)), 64)
		wei.Once_Burn_Furnace, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.738*float64(num.Once_Burn_Furnace)), 64)
		wei.Green_Body, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.738*float64(num.Green_Body)), 64)
	case "IP-2250":
		wei.Finish_Product, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", 0.65*float64(num.Finish_Product)), 64)
		wei.RoughCast, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.805*float64(num.RoughCast)), 64)
		wei.Graphitization_Furnace, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.828*float64(num.Graphitization_Furnace)), 64)
		wei.Second_Burn, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.828*float64(num.Second_Burn)), 64)
		wei.Second_Burn_Furnace, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.898*float64(num.Second_Burn_Furnace)), 64)
		wei.Once_Dip, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.898*float64(num.Once_Dip)), 64)
		wei.Once_Burn, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", 0.78*float64(num.Once_Burn)), 64)
		wei.Once_Burn_Furnace, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.845*float64(num.Once_Burn_Furnace)), 64)
		wei.Green_Body, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.845*float64(num.Green_Body)), 64)
	case "HP-1950":
		wei.Finish_Product, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", 0.65*float64(num.Finish_Product)), 64)
		wei.RoughCast, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.805*float64(num.RoughCast)), 64)
		wei.Graphitization_Furnace, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.828*float64(num.Graphitization_Furnace)), 64)
		wei.Second_Burn, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.828*float64(num.Second_Burn)), 64)
		wei.Second_Burn_Furnace, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.898*float64(num.Second_Burn_Furnace)), 64)
		wei.Once_Dip, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.898*float64(num.Once_Dip)), 64)
		wei.Once_Burn, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", 0.78*float64(num.Once_Burn)), 64)
		wei.Once_Burn_Furnace, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.845*float64(num.Once_Burn_Furnace)), 64)
		wei.Green_Body, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.845*float64(num.Green_Body)), 64)
	case "UHP-1950":
		wei.Finish_Product, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", 0.65*float64(num.Finish_Product)), 64)
		wei.RoughCast, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.805*float64(num.RoughCast)), 64)
		wei.Graphitization_Furnace, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.828*float64(num.Graphitization_Furnace)), 64)
		wei.Second_Burn, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.828*float64(num.Second_Burn)), 64)
		wei.Second_Burn_Furnace, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.898*float64(num.Second_Burn_Furnace)), 64)
		wei.Once_Dip, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.898*float64(num.Once_Dip)), 64)
		wei.Once_Burn, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", 0.78*float64(num.Once_Burn)), 64)
		wei.Once_Burn_Furnace, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.845*float64(num.Once_Burn_Furnace)), 64)
		wei.Green_Body, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.845*float64(num.Green_Body)), 64)
	case "UHP-2250":
		wei.Finish_Product, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", 0.65*float64(num.Finish_Product)), 64)
		wei.RoughCast, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.815*float64(num.RoughCast)), 64)
		wei.Graphitization_Furnace, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", 0.84*float64(num.Graphitization_Furnace)), 64)
		wei.Second_Burn, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", 0.84*float64(num.Second_Burn)), 64)
		wei.Second_Burn_Furnace, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", 0.91*float64(num.Second_Burn_Furnace)), 64)
		wei.Once_Dip, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", 0.91*float64(num.Once_Dip)), 64)
		wei.Once_Burn, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", 0.79*float64(num.Once_Burn)), 64)
		wei.Once_Burn_Furnace, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", 0.848*float64(num.Once_Burn_Furnace)), 64)
		wei.Green_Body, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", 0.848*float64(num.Green_Body)), 64)
	}
	_,err := collection.UpdateOne(context.Background(), bson.M{"time_stamp":wei.Time_Stamp},bson.M{"$set": wei})
	if err != nil {
		fmt.Println(err)
	}

	//同步汇总表
	parts := strings.SplitN(wei.Process_Length, "-", 2)
	var cargo model.CargoSummary
	var tmp = wei.Diameter + parts[0]
	CargoSummary := db.Collection("CargoSummary")
	err = CargoSummary.FindOne(context.Background(), bson.M{"process_specifications": tmp}).Decode(&cargo)
	if err!= nil {
		log.Println(err)
	} else {
		cargo.Finish_Product,_ = strconv.ParseFloat(fmt.Sprintf("%.1f",wei.Finish_Product ), 64)
		cargo.RoughCast,_ = strconv.ParseFloat(fmt.Sprintf("%.1f",wei.RoughCast ), 64)
		cargo.Second_Burn,_ = strconv.ParseFloat(fmt.Sprintf("%.1f",wei.Second_Burn + wei.Second_Burn_Furnace ), 64)
		cargo.Once_Dip,_ =strconv.ParseFloat(fmt.Sprintf("%.1f",wei.Once_Dip ), 64)
		cargo.Once_Burn,_ = strconv.ParseFloat(fmt.Sprintf("%.1f",wei.Once_Burn), 64)
		cargo.Green_Body,_ = strconv.ParseFloat(fmt.Sprintf("%.1f", wei.Once_Burn_Furnace + wei.Green_Body), 64)
		cargo.Time_Stamp = wei.Time_Stamp
		cargo.Diameter = wei.Diameter

		util.UpdateOne1(c,"CargoSummary",cargo,"_id",cargo.Id)
	}
	return wei
}
//直径450
func UpdateWeight450(c *gin.Context,num model.Amount,col string) interface{}{
	db := database.GetMongoDB()
	collection := db.Collection(col)
	var wei model.Weight
	wei.Diameter = num.Diameter
	wei.Desc = num.Desc
	wei.Process_Length = num.Process_Length
	wei.Time_Stamp = num.Time_Stamp
	switch num.Process_Length {
	case "RP-2250":
		wei.Finish_Product, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", 0.51*float64(num.Finish_Product)), 64)
		wei.RoughCast, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.595*float64(num.RoughCast)), 64)
		wei.Graphitization_Furnace, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", 0.63*float64(num.Graphitization_Furnace)), 64)
		wei.Second_Burn = float64(num.Second_Burn)
		wei.Second_Burn_Furnace = float64(num.Second_Burn_Furnace)
		wei.Once_Dip = float64(num.Once_Dip)
		wei.Once_Burn, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", 0.63*float64(num.Once_Burn)), 64)
		wei.Once_Burn_Furnace, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.685*float64(num.Once_Burn_Furnace)), 64)
		wei.Green_Body, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.685*float64(num.Green_Body)), 64)
	case "IP-2":
		wei.Finish_Product, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", 0.53*float64(num.Finish_Product)), 64)
		wei.RoughCast, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.618*float64(num.RoughCast)), 64)
		wei.Graphitization_Furnace, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.651*float64(num.Graphitization_Furnace)), 64)
		wei.Second_Burn, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.664*float64(num.Second_Burn)), 64)
		wei.Second_Burn_Furnace, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.721*float64(num.Second_Burn_Furnace)), 64)
		wei.Once_Dip, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.721*float64(num.Once_Dip)), 64)
		wei.Once_Burn, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", 0.63*float64(num.Once_Burn)), 64)
		wei.Once_Burn_Furnace, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.785*float64(num.Once_Burn_Furnace)), 64)
		wei.Green_Body, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.785*float64(num.Green_Body)), 64)
	case "HP-2100":
		wei.Finish_Product, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", 0.5*float64(num.Finish_Product)), 64)
		wei.RoughCast, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.65*float64(num.RoughCast)), 64)
		wei.Graphitization_Furnace, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.635*float64(num.Graphitization_Furnace)), 64)
		wei.Second_Burn, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.635*float64(num.Second_Burn)), 64)
		wei.Second_Burn_Furnace, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.686*float64(num.Second_Burn_Furnace)), 64)
		wei.Once_Dip, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.686*float64(num.Once_Dip)), 64)
		wei.Once_Burn, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", 0.59*float64(num.Once_Burn)), 64)
		wei.Once_Burn_Furnace, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.646*float64(num.Once_Burn_Furnace)), 64)
		wei.Green_Body, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.646*float64(num.Green_Body)), 64)
	case "HP-2100-2":
		wei.Finish_Product, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", 0.53*float64(num.Finish_Product)), 64)
		wei.RoughCast, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.618*float64(num.RoughCast)), 64)
		wei.Graphitization_Furnace, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.635*float64(num.Graphitization_Furnace)), 64)
		wei.Second_Burn, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.635*float64(num.Second_Burn)), 64)
		wei.Second_Burn_Furnace, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.686*float64(num.Second_Burn_Furnace)), 64)
		wei.Once_Dip, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.686*float64(num.Once_Dip)), 64)
		wei.Once_Burn, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", 0.59*float64(num.Once_Burn)), 64)
		wei.Once_Burn_Furnace, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.646*float64(num.Once_Burn_Furnace)), 64)
		wei.Green_Body, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.646*float64(num.Green_Body)), 64)
	case "HP-2250":
		wei.Finish_Product, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", 0.53*float64(num.Finish_Product)), 64)
		wei.RoughCast, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.607*float64(num.RoughCast)), 64)
		wei.Graphitization_Furnace, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.667*float64(num.Graphitization_Furnace)), 64)
		wei.Second_Burn, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.667*float64(num.Second_Burn)), 64)
		wei.Second_Burn_Furnace, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.722*float64(num.Second_Burn_Furnace)), 64)
		wei.Once_Dip, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.722*float64(num.Once_Dip)), 64)
		wei.Once_Burn, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", 0.63*float64(num.Once_Burn)), 64)
		wei.Once_Burn_Furnace, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.686*float64(num.Once_Burn_Furnace)), 64)
		wei.Green_Body, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.686*float64(num.Green_Body)), 64)
	case "UHP-2150":
		wei.Finish_Product, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", 0.55*float64(num.Finish_Product)), 64)
		wei.RoughCast, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.625*float64(num.RoughCast)), 64)
		wei.Graphitization_Furnace, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.645*float64(num.Graphitization_Furnace)), 64)
		wei.Second_Burn, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.645*float64(num.Second_Burn)), 64)
		wei.Second_Burn_Furnace, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", 0.7*float64(num.Second_Burn_Furnace)), 64)
		wei.Once_Dip, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", 0.7*float64(num.Once_Dip)), 64)
		wei.Once_Burn, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", 0.61*float64(num.Once_Burn)), 64)
		wei.Once_Burn_Furnace, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.656*float64(num.Once_Burn_Furnace)), 64)
		wei.Green_Body, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.656*float64(num.Green_Body)), 64)
	case "UHP-2600":
		wei.Finish_Product = float64(num.Finish_Product)
		wei.RoughCast, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", 0.77*float64(num.RoughCast)), 64)
		wei.Graphitization_Furnace, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.793*float64(num.Graphitization_Furnace)), 64)
		wei.Second_Burn, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.793*float64(num.Second_Burn)), 64)
		wei.Second_Burn_Furnace, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", 0.86*float64(num.Second_Burn_Furnace)), 64)
		wei.Once_Dip, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", 0.86*float64(num.Once_Dip)), 64)
		wei.Once_Burn, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.748*float64(num.Once_Burn)), 64)
		wei.Once_Burn_Furnace, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.806*float64(num.Once_Burn_Furnace)), 64)
		wei.Green_Body, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.806*float64(num.Green_Body)), 64)
	}
	_,err := collection.UpdateOne(context.Background(), bson.M{"time_stamp":wei.Time_Stamp},bson.M{"$set": wei})
	if err != nil {
		fmt.Println(err)
	}

	//同步汇总表
	parts := strings.SplitN(wei.Process_Length, "-", 2)
	var cargo model.CargoSummary
	var tmp = wei.Diameter + parts[0]
	CargoSummary := db.Collection("CargoSummary")
	err = CargoSummary.FindOne(context.Background(), bson.M{"process_specifications": tmp}).Decode(&cargo)
	if err!= nil {
		log.Println(err)
	} else {
		cargo.Finish_Product,_ = strconv.ParseFloat(fmt.Sprintf("%.1f",wei.Finish_Product ), 64)
		cargo.RoughCast,_ = strconv.ParseFloat(fmt.Sprintf("%.1f",wei.RoughCast ), 64)
		cargo.Second_Burn,_ = strconv.ParseFloat(fmt.Sprintf("%.1f",wei.Second_Burn + wei.Second_Burn_Furnace ), 64)
		cargo.Once_Dip,_ =strconv.ParseFloat(fmt.Sprintf("%.1f",wei.Once_Dip ), 64)
		cargo.Once_Burn,_ = strconv.ParseFloat(fmt.Sprintf("%.1f",wei.Once_Burn), 64)
		cargo.Green_Body,_ = strconv.ParseFloat(fmt.Sprintf("%.1f", wei.Once_Burn_Furnace + wei.Green_Body), 64)
		cargo.Time_Stamp = wei.Time_Stamp
		cargo.Diameter = wei.Diameter

		util.UpdateOne1(c,"CargoSummary",cargo,"_id",cargo.Id)
	}
	return wei
}
//直径400
func UpdateWeight400(c *gin.Context,num model.Amount,col string) interface{}{
	db := database.GetMongoDB()
	collection := db.Collection(col)
	var wei model.Weight
	wei.Diameter = num.Diameter
	wei.Desc = num.Desc
	wei.Process_Length = num.Process_Length
	wei.Time_Stamp = num.Time_Stamp
	switch num.Process_Length {
	case "RP-2000":
		wei.Finish_Product, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", 0.38*float64(num.Finish_Product)), 64)
		wei.RoughCast, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.441*float64(num.RoughCast)), 64)
		wei.Graphitization_Furnace, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", 0.46*float64(num.Graphitization_Furnace)), 64)
		wei.Second_Burn = float64(num.Second_Burn)
		wei.Second_Burn_Furnace = float64(num.Second_Burn_Furnace)
		wei.Once_Dip = float64(num.Once_Dip)
		wei.Once_Burn, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", 0.46*float64(num.Once_Burn)), 64)
		wei.Once_Burn_Furnace, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.497*float64(num.Once_Burn_Furnace)), 64)
		wei.Green_Body, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.497*float64(num.Green_Body)), 64)
	case "IP-2000":
		wei.Finish_Product, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", 0.39*float64(num.Finish_Product)), 64)
		wei.RoughCast, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.465*float64(num.RoughCast)), 64)
		wei.Graphitization_Furnace, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.497*float64(num.Graphitization_Furnace)), 64)
		wei.Second_Burn, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.497*float64(num.Second_Burn)), 64)
		wei.Second_Burn_Furnace, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.536*float64(num.Second_Burn_Furnace)), 64)
		wei.Once_Dip, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.536*float64(num.Once_Dip)), 64)
		wei.Once_Burn, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", 0.46*float64(num.Once_Burn)), 64)
		wei.Once_Burn_Furnace, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.497*float64(num.Once_Burn_Furnace)), 64)
		wei.Green_Body, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.497*float64(num.Green_Body)), 64)
	case "HP-2000":
		wei.Finish_Product, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", 0.39*float64(num.Finish_Product)), 64)
		wei.RoughCast, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.466*float64(num.RoughCast)), 64)
		wei.Graphitization_Furnace, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.489*float64(num.Graphitization_Furnace)), 64)
		wei.Second_Burn, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.489*float64(num.Second_Burn)), 64)
		wei.Second_Burn_Furnace, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.528*float64(num.Second_Burn_Furnace)), 64)
		wei.Once_Dip, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.528*float64(num.Once_Dip)), 64)
		wei.Once_Burn, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.457*float64(num.Once_Burn)), 64)
		wei.Once_Burn_Furnace, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.492*float64(num.Once_Burn_Furnace)), 64)
		wei.Green_Body, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.492*float64(num.Green_Body)), 64)
	case "HP-2":
		wei.Finish_Product, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", 0.39*float64(num.Finish_Product)), 64)
		wei.RoughCast, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.466*float64(num.RoughCast)), 64)
		wei.Graphitization_Furnace, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.489*float64(num.Graphitization_Furnace)), 64)
		wei.Second_Burn, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.489*float64(num.Second_Burn)), 64)
		wei.Second_Burn_Furnace, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.528*float64(num.Second_Burn_Furnace)), 64)
		wei.Once_Dip, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.528*float64(num.Once_Dip)), 64)
		wei.Once_Burn, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.457*float64(num.Once_Burn)), 64)
		wei.Once_Burn_Furnace, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.492*float64(num.Once_Burn_Furnace)), 64)
		wei.Green_Body, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.492*float64(num.Green_Body)), 64)
	case "HP-2200":
		wei.Finish_Product, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", 0.39*float64(num.Finish_Product)), 64)
		wei.RoughCast, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", 0.51*float64(num.RoughCast)), 64)
		wei.Graphitization_Furnace, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.527*float64(num.Graphitization_Furnace)), 64)
		wei.Second_Burn, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.527*float64(num.Second_Burn)), 64)
		wei.Second_Burn_Furnace, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.572*float64(num.Second_Burn_Furnace)), 64)
		wei.Once_Dip, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.572*float64(num.Once_Dip)), 64)
		wei.Once_Burn, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.495*float64(num.Once_Burn)), 64)
		wei.Once_Burn_Furnace, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.541*float64(num.Once_Burn_Furnace)), 64)
		wei.Green_Body, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.541*float64(num.Green_Body)), 64)
	case "UHP-2200":
		wei.Finish_Product, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", 0.4*float64(num.Finish_Product)), 64)
		wei.RoughCast, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", 0.51*float64(num.RoughCast)), 64)
		wei.Graphitization_Furnace, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.527*float64(num.Graphitization_Furnace)), 64)
		wei.Second_Burn, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.527*float64(num.Second_Burn)), 64)
		wei.Second_Burn_Furnace, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.572*float64(num.Second_Burn_Furnace)), 64)
		wei.Once_Dip, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.572*float64(num.Once_Dip)), 64)
		wei.Once_Burn, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.495*float64(num.Once_Burn)), 64)
		wei.Once_Burn_Furnace, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.541*float64(num.Once_Burn_Furnace)), 64)
		wei.Green_Body, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.541*float64(num.Green_Body)), 64)
	}
	_,err := collection.UpdateOne(context.Background(), bson.M{"time_stamp":wei.Time_Stamp},bson.M{"$set": wei})
	if err != nil {
		fmt.Println(err)
	}

	//同步汇总表
	parts := strings.SplitN(wei.Process_Length, "-", 2)
	var cargo model.CargoSummary
	var tmp = wei.Diameter + parts[0]
	CargoSummary := db.Collection("CargoSummary")
	err = CargoSummary.FindOne(context.Background(), bson.M{"process_specifications": tmp}).Decode(&cargo)
	if err!= nil {
		log.Println(err)
	} else {
		cargo.Finish_Product,_ = strconv.ParseFloat(fmt.Sprintf("%.1f",wei.Finish_Product ), 64)
		cargo.RoughCast,_ = strconv.ParseFloat(fmt.Sprintf("%.1f",wei.RoughCast ), 64)
		cargo.Second_Burn,_ = strconv.ParseFloat(fmt.Sprintf("%.1f",wei.Second_Burn + wei.Second_Burn_Furnace ), 64)
		cargo.Once_Dip,_ =strconv.ParseFloat(fmt.Sprintf("%.1f",wei.Once_Dip ), 64)
		cargo.Once_Burn,_ = strconv.ParseFloat(fmt.Sprintf("%.1f",wei.Once_Burn), 64)
		cargo.Green_Body,_ = strconv.ParseFloat(fmt.Sprintf("%.1f", wei.Once_Burn_Furnace + wei.Green_Body), 64)
		cargo.Time_Stamp = wei.Time_Stamp
		cargo.Diameter = wei.Diameter

		util.UpdateOne1(c,"CargoSummary",cargo,"_id",cargo.Id)
	}
	return wei
}
//直径350
func UpdateWeight350(c *gin.Context,num model.Amount,col string) interface{}{
	db := database.GetMongoDB()
	collection := db.Collection(col)
	var wei model.Weight
	wei.Diameter = num.Diameter
	wei.Desc = num.Desc
	wei.Process_Length = num.Process_Length
	wei.Time_Stamp = num.Time_Stamp
	switch num.Process_Length {
	case "RP":
		wei.Finish_Product, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", 0.33*float64(num.Finish_Product)), 64)
		wei.RoughCast, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.346*float64(num.RoughCast)), 64)
		wei.Graphitization_Furnace, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", 0.35*float64(num.Graphitization_Furnace)), 64)
		wei.Second_Burn = float64(num.Second_Burn)
		wei.Second_Burn_Furnace = float64(num.Second_Burn_Furnace)
		wei.Once_Dip = float64(num.Once_Dip)
		wei.Once_Burn, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", 0.35*float64(num.Once_Burn)), 64)
		wei.Once_Burn_Furnace, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.383*float64(num.Once_Burn_Furnace)), 64)
		wei.Green_Body, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.383*float64(num.Green_Body)), 64)
	case "IP-2":
		wei.Finish_Product, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", 0.3*float64(num.Finish_Product)), 64)
		wei.RoughCast, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", 0.36*float64(num.RoughCast)), 64)
		wei.Graphitization_Furnace, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.386*float64(num.Graphitization_Furnace)), 64)
		wei.Second_Burn, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.386*float64(num.Second_Burn)), 64)
		wei.Second_Burn_Furnace, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.418*float64(num.Second_Burn_Furnace)), 64)
		wei.Once_Dip, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.418*float64(num.Once_Dip)), 64)
		wei.Once_Burn, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", 0.35*float64(num.Once_Burn)), 64)
		wei.Once_Burn_Furnace, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.383*float64(num.Once_Burn_Furnace)), 64)
		wei.Green_Body, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.383*float64(num.Green_Body)), 64)
	case "HP-2":
		wei.Finish_Product, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", 0.3*float64(num.Finish_Product)), 64)
		wei.RoughCast, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.358*float64(num.RoughCast)), 64)
		wei.Graphitization_Furnace, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.376*float64(num.Graphitization_Furnace)), 64)
		wei.Second_Burn, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.376*float64(num.Second_Burn)), 64)
		wei.Second_Burn_Furnace, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.407*float64(num.Second_Burn_Furnace)), 64)
		wei.Once_Dip, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.407*float64(num.Once_Dip)), 64)
		wei.Once_Burn, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.357*float64(num.Once_Burn)), 64)
		wei.Once_Burn_Furnace, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.387*float64(num.Once_Burn_Furnace)), 64)
		wei.Green_Body, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.387*float64(num.Green_Body)), 64)
	}
	_,err := collection.UpdateOne(context.Background(), bson.M{"time_stamp":wei.Time_Stamp},bson.M{"$set": wei})
	if err != nil {
		fmt.Println(err)
	}

	//同步汇总表
	var  tmp string
	var cargo model.CargoSummary
	if wei.Process_Length == "RP"{
		tmp = wei.Diameter + "RP"
	}else {
		parts := strings.SplitN(wei.Process_Length, "-", 2)
		tmp = wei.Diameter + parts[0]
	}
	CargoSummary := db.Collection("CargoSummary")
	err = CargoSummary.FindOne(context.Background(), bson.M{"process_specifications": tmp}).Decode(&cargo)
	if err!= nil {
		log.Println(err)
	} else {
		cargo.Finish_Product,_ = strconv.ParseFloat(fmt.Sprintf("%.1f",wei.Finish_Product ), 64)
		cargo.RoughCast,_ = strconv.ParseFloat(fmt.Sprintf("%.1f",wei.RoughCast ), 64)
		cargo.Second_Burn,_ = strconv.ParseFloat(fmt.Sprintf("%.1f",wei.Second_Burn + wei.Second_Burn_Furnace ), 64)
		cargo.Once_Dip,_ =strconv.ParseFloat(fmt.Sprintf("%.1f",wei.Once_Dip ), 64)
		cargo.Once_Burn,_ = strconv.ParseFloat(fmt.Sprintf("%.1f",wei.Once_Burn), 64)
		cargo.Green_Body,_ = strconv.ParseFloat(fmt.Sprintf("%.1f", wei.Once_Burn_Furnace + wei.Green_Body), 64)
		cargo.Time_Stamp = wei.Time_Stamp
		cargo.Diameter = wei.Diameter

		util.UpdateOne1(c,"CargoSummary",cargo,"_id",cargo.Id)
	}
	return wei
}
//直径300
func UpdateWeight300(c *gin.Context,num model.Amount,col string) interface{}{
	db := database.GetMongoDB()
	collection := db.Collection(col)
	var wei model.Weight
	wei.Diameter = num.Diameter
	wei.Desc = num.Desc
	wei.Process_Length = num.Process_Length
	wei.Time_Stamp = num.Time_Stamp
	switch num.Process_Length {
	case "RP":
		wei.Finish_Product, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.215*float64(num.Finish_Product)), 64)
		wei.RoughCast, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.251*float64(num.RoughCast)), 64)
		wei.Graphitization_Furnace, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", 0.27*float64(num.Graphitization_Furnace)), 64)
		wei.Second_Burn = float64(num.Second_Burn)
		wei.Second_Burn_Furnace = float64(num.Second_Burn_Furnace)
		wei.Once_Dip = float64(num.Once_Dip)
		wei.Once_Burn, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", 0.27*float64(num.Once_Burn)), 64)
		wei.Once_Burn_Furnace, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.292*float64(num.Once_Burn_Furnace)), 64)
		wei.Green_Body, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.292*float64(num.Green_Body)), 64)
	case "IP-2":
		wei.Finish_Product, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", 0.26*float64(num.Finish_Product)), 64)
		wei.RoughCast, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.268*float64(num.RoughCast)), 64)
		wei.Graphitization_Furnace, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.288*float64(num.Graphitization_Furnace)), 64)
		wei.Second_Burn, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.288*float64(num.Second_Burn)), 64)
		wei.Second_Burn_Furnace, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.312*float64(num.Second_Burn_Furnace)), 64)
		wei.Once_Dip, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.312*float64(num.Once_Dip)), 64)
		wei.Once_Burn, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", 0.27*float64(num.Once_Burn)), 64)
		wei.Once_Burn_Furnace, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.292*float64(num.Once_Burn_Furnace)), 64)
		wei.Green_Body, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.292*float64(num.Green_Body)), 64)
	}
	_,err := collection.UpdateOne(context.Background(), bson.M{"time_stamp":wei.Time_Stamp},bson.M{"$set": wei})
	if err != nil {
		fmt.Println(err)
	}

	//同步汇总表
	var  tmp string
	var cargo model.CargoSummary
	if wei.Process_Length == "RP"{
		tmp = wei.Diameter + "RP"
	}else {
		parts := strings.SplitN(wei.Process_Length, "-", 2)
		tmp = wei.Diameter + parts[0]
	}
	CargoSummary := db.Collection("CargoSummary")
	err = CargoSummary.FindOne(context.Background(), bson.M{"process_specifications": tmp}).Decode(&cargo)
	if err!= nil {
		log.Println(err)
	} else {
		cargo.Finish_Product,_ = strconv.ParseFloat(fmt.Sprintf("%.1f",wei.Finish_Product ), 64)
		cargo.RoughCast,_ = strconv.ParseFloat(fmt.Sprintf("%.1f",wei.RoughCast ), 64)
		cargo.Second_Burn,_ = strconv.ParseFloat(fmt.Sprintf("%.1f",wei.Second_Burn + wei.Second_Burn_Furnace ), 64)
		cargo.Once_Dip,_ =strconv.ParseFloat(fmt.Sprintf("%.1f",wei.Once_Dip ), 64)
		cargo.Once_Burn,_ = strconv.ParseFloat(fmt.Sprintf("%.1f",wei.Once_Burn), 64)
		cargo.Green_Body,_ = strconv.ParseFloat(fmt.Sprintf("%.1f", wei.Once_Burn_Furnace + wei.Green_Body), 64)
		cargo.Time_Stamp = wei.Time_Stamp
		cargo.Diameter = wei.Diameter

		util.UpdateOne1(c,"CargoSummary",cargo,"_id",cargo.Id)
	}
	return wei
}
//直径250
func UpdateWeight250(c *gin.Context,num model.Amount,col string) interface{}{
	db := database.GetMongoDB()
	collection := db.Collection(col)
	var wei model.Weight
	wei.Diameter = num.Diameter
	wei.Desc = num.Desc
	wei.Process_Length = num.Process_Length
	wei.Time_Stamp = num.Time_Stamp
	switch num.Process_Length {
	case "RP-1700":
		wei.Finish_Product, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.135*float64(num.Finish_Product)), 64)
		wei.RoughCast, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.155*float64(num.RoughCast)), 64)
		wei.Graphitization_Furnace, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.179*float64(num.Graphitization_Furnace)), 64)
		wei.Second_Burn = float64(num.Second_Burn)
		wei.Second_Burn_Furnace = float64(num.Second_Burn_Furnace)
		wei.Once_Dip = float64(num.Once_Dip)
		wei.Once_Burn, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.179*float64(num.Once_Burn)), 64)
		wei.Once_Burn_Furnace, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.194*float64(num.Once_Burn_Furnace)), 64)
		wei.Green_Body, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.194*float64(num.Green_Body)), 64)
	case "RP-1900":
		wei.Finish_Product, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", 0.15*float64(num.Finish_Product)), 64)
		wei.RoughCast, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.173*float64(num.RoughCast)), 64)
		wei.Graphitization_Furnace, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.179*float64(num.Graphitization_Furnace)), 64)
		wei.Second_Burn = float64(num.Second_Burn)
		wei.Second_Burn_Furnace = float64(num.Second_Burn_Furnace)
		wei.Once_Dip = float64(num.Once_Dip)
		wei.Once_Burn, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.179*float64(num.Once_Burn)), 64)
		wei.Once_Burn_Furnace, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.194*float64(num.Once_Burn_Furnace)), 64)
		wei.Green_Body, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.194*float64(num.Green_Body)), 64)
	case "IP-2-1700":
		wei.Finish_Product, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.135*float64(num.Finish_Product)), 64)
		wei.RoughCast, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", 0.16*float64(num.RoughCast)), 64)
		wei.Graphitization_Furnace, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.188*float64(num.Graphitization_Furnace)), 64)
		wei.Second_Burn, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.188*float64(num.Second_Burn)), 64)
		wei.Second_Burn_Furnace, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.192*float64(num.Second_Burn_Furnace)), 64)
		wei.Once_Dip, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.192*float64(num.Once_Dip)), 64)
		wei.Once_Burn, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.179*float64(num.Once_Burn)), 64)
		wei.Once_Burn_Furnace, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.194*float64(num.Once_Burn_Furnace)), 64)
		wei.Green_Body, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.194*float64(num.Green_Body)), 64)
	case "IP-2-1900":
		wei.Finish_Product, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", 0.16*float64(num.Finish_Product)), 64)
		wei.RoughCast, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.185*float64(num.RoughCast)), 64)
		wei.Graphitization_Furnace, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.188*float64(num.Graphitization_Furnace)), 64)
		wei.Second_Burn, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.188*float64(num.Second_Burn)), 64)
		wei.Second_Burn_Furnace, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.192*float64(num.Second_Burn_Furnace)), 64)
		wei.Once_Dip, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.192*float64(num.Once_Dip)), 64)
		wei.Once_Burn, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.179*float64(num.Once_Burn)), 64)
		wei.Once_Burn_Furnace, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.194*float64(num.Once_Burn_Furnace)), 64)
		wei.Green_Body, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.194*float64(num.Green_Body)), 64)
	}
	_,err := collection.UpdateOne(context.Background(), bson.M{"time_stamp":wei.Time_Stamp},bson.M{"$set": wei})
	if err != nil {
		fmt.Println(err)
	}

	//同步汇总表
	parts := strings.SplitN(wei.Process_Length, "-", 2)
	var cargo model.CargoSummary
	var tmp = wei.Diameter + parts[0]
	CargoSummary := db.Collection("CargoSummary")
	err = CargoSummary.FindOne(context.Background(), bson.M{"process_specifications": tmp}).Decode(&cargo)
	if err!= nil {
		log.Println(err)
	} else {
		cargo.Finish_Product,_ = strconv.ParseFloat(fmt.Sprintf("%.1f",wei.Finish_Product ), 64)
		cargo.RoughCast,_ = strconv.ParseFloat(fmt.Sprintf("%.1f",wei.RoughCast ), 64)
		cargo.Second_Burn,_ = strconv.ParseFloat(fmt.Sprintf("%.1f",wei.Second_Burn + wei.Second_Burn_Furnace ), 64)
		cargo.Once_Dip,_ =strconv.ParseFloat(fmt.Sprintf("%.1f",wei.Once_Dip ), 64)
		cargo.Once_Burn,_ = strconv.ParseFloat(fmt.Sprintf("%.1f",wei.Once_Burn), 64)
		cargo.Green_Body,_ = strconv.ParseFloat(fmt.Sprintf("%.1f", wei.Once_Burn_Furnace + wei.Green_Body), 64)
		cargo.Time_Stamp = wei.Time_Stamp
		cargo.Diameter = wei.Diameter

		util.UpdateOne1(c,"CargoSummary",cargo,"_id",cargo.Id)
	}
	return wei
}
////直径200
func UpdateWeight200(c *gin.Context,num model.Amount,col string) interface{}{
	db := database.GetMongoDB()
	collection := db.Collection(col)
	var wei model.Weight
	wei.Diameter = num.Diameter
	wei.Desc = num.Desc
	wei.Process_Length = num.Process_Length
	wei.Time_Stamp = num.Time_Stamp
	//公式部分
	wei.Finish_Product, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", 0.1*float64(num.Finish_Product)), 64)
	wei.RoughCast, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.112*float64(num.RoughCast)), 64)
	wei.Graphitization_Furnace, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.114*float64(num.Graphitization_Furnace)), 64)
	wei.Second_Burn = float64(num.Second_Burn)
	wei.Second_Burn_Furnace = float64(num.Second_Burn_Furnace)
	wei.Once_Dip = float64(num.Once_Dip)
	wei.Once_Burn, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.114*float64(num.Once_Burn)), 64)
	wei.Once_Burn_Furnace, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.123*float64(num.Once_Burn_Furnace)), 64)
	wei.Green_Body, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.123*float64(num.Green_Body)), 64)
	_,err := collection.UpdateOne(context.Background(), bson.M{"time_stamp":wei.Time_Stamp},bson.M{"$set": wei})
	if err != nil {
		fmt.Println(err)
	}

	//同步汇总表
	var  tmp string
	var cargo model.CargoSummary
	if wei.Process_Length == "RP"{
		tmp = wei.Diameter + "RP"
	}else {
		parts := strings.SplitN(wei.Process_Length, "-", 2)
		tmp = wei.Diameter + parts[0]
	}
	CargoSummary := db.Collection("CargoSummary")
	err = CargoSummary.FindOne(context.Background(), bson.M{"process_specifications": tmp}).Decode(&cargo)
	if err!= nil {
		log.Println(err)
	} else {
		cargo.Finish_Product,_ = strconv.ParseFloat(fmt.Sprintf("%.1f",wei.Finish_Product ), 64)
		cargo.RoughCast,_ = strconv.ParseFloat(fmt.Sprintf("%.1f",wei.RoughCast ), 64)
		cargo.Second_Burn,_ = strconv.ParseFloat(fmt.Sprintf("%.1f",wei.Second_Burn + wei.Second_Burn_Furnace ), 64)
		cargo.Once_Dip,_ =strconv.ParseFloat(fmt.Sprintf("%.1f",wei.Once_Dip ), 64)
		cargo.Once_Burn,_ = strconv.ParseFloat(fmt.Sprintf("%.1f",wei.Once_Burn), 64)
		cargo.Green_Body,_ = strconv.ParseFloat(fmt.Sprintf("%.1f", wei.Once_Burn_Furnace + wei.Green_Body), 64)
		cargo.Time_Stamp = wei.Time_Stamp
		cargo.Diameter = wei.Diameter

		util.UpdateOne1(c,"CargoSummary",cargo,"_id",cargo.Id)
	}
	return wei
}
//直径234
func UpdateWeight234(c *gin.Context,num model.Amount,col string) interface{}{
	db := database.GetMongoDB()
	collection := db.Collection(col)
	var wei model.Weight
	wei.Diameter = num.Diameter
	wei.Desc = num.Desc
	wei.Process_Length = num.Process_Length
	wei.Time_Stamp = num.Time_Stamp
	switch num.Process_Length {
	case "IP(白点)":
		wei.Finish_Product = float64(num.Finish_Product)
		wei.RoughCast, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", 0.15*float64(num.RoughCast)), 64)
		wei.Graphitization_Furnace, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.155*float64(num.Graphitization_Furnace)), 64)
		wei.Forth_Burn, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.155*float64(num.Forth_Burn)), 64)
		wei.Third_Dip, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.163*float64(num.Third_Dip)), 64)
		wei.Third_Burn, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.151*float64(num.Third_Burn)), 64)
		wei.Second_Dip, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.162*float64(num.Second_Dip)), 64)
		wei.Second_Burn, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", 0.15*float64(num.Once_Burn_Furnace)), 64)
		wei.Second_Burn_Furnace, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.159*float64(num.Second_Burn_Furnace)), 64)
		wei.Once_Dip, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.159*float64(num.Once_Dip)), 64)
		wei.Once_Burn, _ =strconv.ParseFloat(fmt.Sprintf("%.3f", 0.141*float64(num.Once_Burn)), 64)
		wei.Once_Burn_Furnace, _ =strconv.ParseFloat(fmt.Sprintf("%.3f", 0.152*float64(num.Once_Burn_Furnace)), 64)
		wei.Green_Body, _ =strconv.ParseFloat(fmt.Sprintf("%.3f", 0.152*float64(num.Green_Body)), 64)
	case "IP(黄点)":
		wei.Finish_Product = float64(num.Finish_Product)
		wei.RoughCast, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", 0.15*float64(num.RoughCast)), 64)
		wei.Graphitization_Furnace, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.155*float64(num.Graphitization_Furnace)), 64)
		wei.Forth_Burn, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.155*float64(num.Forth_Burn)), 64)
		wei.Third_Dip, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.163*float64(num.Third_Dip)), 64)
		wei.Third_Burn, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.151*float64(num.Third_Burn)), 64)
		wei.Second_Dip, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.162*float64(num.Second_Dip)), 64)
		wei.Second_Burn, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", 0.15*float64(num.Once_Burn_Furnace)), 64)
		wei.Second_Burn_Furnace, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.159*float64(num.Second_Burn_Furnace)), 64)
		wei.Once_Dip, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.159*float64(num.Once_Dip)), 64)
		wei.Once_Burn, _ =strconv.ParseFloat(fmt.Sprintf("%.3f", 0.141*float64(num.Once_Burn)), 64)
		wei.Once_Burn_Furnace, _ =strconv.ParseFloat(fmt.Sprintf("%.3f", 0.152*float64(num.Once_Burn_Furnace)), 64)
		wei.Green_Body, _ =strconv.ParseFloat(fmt.Sprintf("%.3f", 0.152*float64(num.Green_Body)), 64)
	case "IP(红点)":
		wei.Finish_Product = float64(num.Finish_Product)
		wei.RoughCast, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", 0.15*float64(num.RoughCast)), 64)
		wei.Graphitization_Furnace, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.155*float64(num.Graphitization_Furnace)), 64)
		wei.Forth_Burn, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.155*float64(num.Forth_Burn)), 64)
		wei.Third_Dip, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.163*float64(num.Third_Dip)), 64)
		wei.Third_Burn, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.151*float64(num.Third_Burn)), 64)
		wei.Second_Dip, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.162*float64(num.Second_Dip)), 64)
		wei.Second_Burn, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", 0.15*float64(num.Once_Burn_Furnace)), 64)
		wei.Second_Burn_Furnace, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.159*float64(num.Second_Burn_Furnace)), 64)
		wei.Once_Dip, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.159*float64(num.Once_Dip)), 64)
		wei.Once_Burn, _ =strconv.ParseFloat(fmt.Sprintf("%.3f", 0.141*float64(num.Once_Burn)), 64)
		wei.Once_Burn_Furnace, _ =strconv.ParseFloat(fmt.Sprintf("%.3f", 0.152*float64(num.Once_Burn_Furnace)), 64)
		wei.Green_Body, _ =strconv.ParseFloat(fmt.Sprintf("%.3f", 0.152*float64(num.Green_Body)), 64)
	}
	_,err := collection.UpdateOne(context.Background(), bson.M{"time_stamp":wei.Time_Stamp},bson.M{"$set": wei})
	if err != nil {
		fmt.Println(err)
	}

	//同步汇总表
	parts := strings.SplitN(wei.Process_Length, "(", 2)
	var cargo model.CargoSummary
	var tmp = wei.Diameter + parts[0]
	CargoSummary := db.Collection("CargoSummary")
	err = CargoSummary.FindOne(context.Background(), bson.M{"process_specifications": tmp}).Decode(&cargo)
	if err!= nil {
		log.Println(err)
	} else {
		cargo.Finish_Product,_ = strconv.ParseFloat(fmt.Sprintf("%.1f",wei.Finish_Product ), 64)
		cargo.RoughCast,_ = strconv.ParseFloat(fmt.Sprintf("%.1f",wei.RoughCast ), 64)
		cargo.Second_Burn,_ = strconv.ParseFloat(fmt.Sprintf("%.1f",wei.Second_Burn + wei.Second_Burn_Furnace ), 64)
		cargo.Once_Dip,_ =strconv.ParseFloat(fmt.Sprintf("%.1f",wei.Once_Dip ), 64)
		cargo.Once_Burn,_ = strconv.ParseFloat(fmt.Sprintf("%.1f",wei.Once_Burn), 64)
		cargo.Green_Body,_ = strconv.ParseFloat(fmt.Sprintf("%.1f", wei.Once_Burn_Furnace + wei.Green_Body), 64)
		cargo.Time_Stamp = wei.Time_Stamp
		cargo.Diameter = wei.Diameter

		util.UpdateOne1(c,"CargoSummary",cargo,"_id",cargo.Id)
	}
	return wei
}
//直径256
func UpdateWeight256(c *gin.Context,num model.Amount,col string) interface{}{
	db := database.GetMongoDB()
	collection := db.Collection(col)
	var wei model.Weight
	wei.Diameter = num.Diameter
	wei.Desc = num.Desc
	wei.Process_Length = num.Process_Length
	wei.Time_Stamp = num.Time_Stamp
	switch num.Process_Length {
	case "IP(白点)":
		wei.Finish_Product = float64(num.Finish_Product)
		wei.RoughCast, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.172*float64(num.RoughCast)), 64)
		wei.Graphitization_Furnace, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.183*float64(num.Graphitization_Furnace)), 64)
		wei.Forth_Burn, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.183*float64(num.Forth_Burn)), 64)
		wei.Third_Dip, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.194*float64(num.Third_Dip)), 64)
		wei.Third_Burn, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.176*float64(num.Third_Burn)), 64)
		wei.Second_Dip, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.181*float64(num.Second_Dip)), 64)
		wei.Second_Burn, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.163*float64(num.Once_Burn_Furnace)), 64)
		wei.Second_Burn_Furnace, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.189*float64(num.Second_Burn_Furnace)), 64)
		wei.Once_Dip, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.189*float64(num.Once_Dip)), 64)
		wei.Once_Burn, _ =strconv.ParseFloat(fmt.Sprintf("%.2f", 0.16*float64(num.Once_Burn)), 64)
		wei.Once_Burn_Furnace, _ =strconv.ParseFloat(fmt.Sprintf("%.3f", 0.173*float64(num.Once_Burn_Furnace)), 64)
		wei.Green_Body, _ =strconv.ParseFloat(fmt.Sprintf("%.3f", 0.173*float64(num.Green_Body)), 64)
	case "IP(黄点)":
		wei.Finish_Product = float64(num.Finish_Product)
		wei.RoughCast, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.172*float64(num.RoughCast)), 64)
		wei.Graphitization_Furnace, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.183*float64(num.Graphitization_Furnace)), 64)
		wei.Forth_Burn, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.183*float64(num.Forth_Burn)), 64)
		wei.Third_Dip, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.194*float64(num.Third_Dip)), 64)
		wei.Third_Burn, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.176*float64(num.Third_Burn)), 64)
		wei.Second_Dip, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.181*float64(num.Second_Dip)), 64)
		wei.Second_Burn, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.163*float64(num.Once_Burn_Furnace)), 64)
		wei.Second_Burn_Furnace, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.189*float64(num.Second_Burn_Furnace)), 64)
		wei.Once_Dip, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.189*float64(num.Once_Dip)), 64)
		wei.Once_Burn, _ =strconv.ParseFloat(fmt.Sprintf("%.2f", 0.16*float64(num.Once_Burn)), 64)
		wei.Once_Burn_Furnace, _ =strconv.ParseFloat(fmt.Sprintf("%.3f", 0.173*float64(num.Once_Burn_Furnace)), 64)
		wei.Green_Body, _ =strconv.ParseFloat(fmt.Sprintf("%.3f", 0.173*float64(num.Green_Body)), 64)
	case "IP(红点)":
		wei.Finish_Product = float64(num.Finish_Product)
		wei.RoughCast, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.172*float64(num.RoughCast)), 64)
		wei.Graphitization_Furnace, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.183*float64(num.Graphitization_Furnace)), 64)
		wei.Forth_Burn, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.183*float64(num.Forth_Burn)), 64)
		wei.Third_Dip, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.194*float64(num.Third_Dip)), 64)
		wei.Third_Burn, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.176*float64(num.Third_Burn)), 64)
		wei.Second_Dip, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.181*float64(num.Second_Dip)), 64)
		wei.Second_Burn, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.163*float64(num.Once_Burn_Furnace)), 64)
		wei.Second_Burn_Furnace, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.189*float64(num.Second_Burn_Furnace)), 64)
		wei.Once_Dip, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.189*float64(num.Once_Dip)), 64)
		wei.Once_Burn, _ =strconv.ParseFloat(fmt.Sprintf("%.2f", 0.16*float64(num.Once_Burn)), 64)
		wei.Once_Burn_Furnace, _ =strconv.ParseFloat(fmt.Sprintf("%.3f", 0.173*float64(num.Once_Burn_Furnace)), 64)
		wei.Green_Body, _ =strconv.ParseFloat(fmt.Sprintf("%.3f", 0.173*float64(num.Green_Body)), 64)
	}
	_,err := collection.UpdateOne(context.Background(), bson.M{"time_stamp":wei.Time_Stamp},bson.M{"$set": wei})
	if err != nil {
		fmt.Println(err)
	}

	//同步汇总表
	parts := strings.SplitN(wei.Process_Length, "(", 2)
	var cargo model.CargoSummary
	var tmp = wei.Diameter + parts[0]
	CargoSummary := db.Collection("CargoSummary")
	err = CargoSummary.FindOne(context.Background(), bson.M{"process_specifications": tmp}).Decode(&cargo)
	if err!= nil {
		log.Println(err)
	} else {
		cargo.Finish_Product,_ = strconv.ParseFloat(fmt.Sprintf("%.1f",wei.Finish_Product ), 64)
		cargo.RoughCast,_ = strconv.ParseFloat(fmt.Sprintf("%.1f",wei.RoughCast ), 64)
		cargo.Second_Burn,_ = strconv.ParseFloat(fmt.Sprintf("%.1f",wei.Second_Burn + wei.Second_Burn_Furnace ), 64)
		cargo.Once_Dip,_ =strconv.ParseFloat(fmt.Sprintf("%.1f",wei.Once_Dip ), 64)
		cargo.Once_Burn,_ = strconv.ParseFloat(fmt.Sprintf("%.1f",wei.Once_Burn), 64)
		cargo.Green_Body,_ = strconv.ParseFloat(fmt.Sprintf("%.1f", wei.Once_Burn_Furnace + wei.Green_Body), 64)
		cargo.Time_Stamp = wei.Time_Stamp
		cargo.Diameter = wei.Diameter

		util.UpdateOne1(c,"CargoSummary",cargo,"_id",cargo.Id)
	}
	return wei
}
//直径288
func UpdateWeight288(c *gin.Context,num model.Amount,col string) interface{}{
	db := database.GetMongoDB()
	collection := db.Collection(col)
	var wei model.Weight
	wei.Diameter = num.Diameter
	wei.Desc = num.Desc
	wei.Process_Length = num.Process_Length
	wei.Time_Stamp = num.Time_Stamp
	switch num.Process_Length {
	case "IP(白点)":
		wei.Finish_Product = float64(num.Finish_Product)
		wei.RoughCast, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", 0.22*float64(num.RoughCast)), 64)
		wei.Graphitization_Furnace, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.227*float64(num.Graphitization_Furnace)), 64)
		wei.Forth_Burn, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.227*float64(num.Forth_Burn)), 64)
		wei.Third_Dip, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", 0.24*float64(num.Third_Dip)), 64)
		wei.Third_Burn, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.218*float64(num.Third_Burn)), 64)
		wei.Second_Dip, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.231*float64(num.Second_Dip)), 64)
		wei.Second_Burn, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.209*float64(num.Once_Burn_Furnace)), 64)
		wei.Second_Burn_Furnace, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", 0.23*float64(num.Second_Burn_Furnace)), 64)
		wei.Once_Dip, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", 0.23*float64(num.Once_Dip)), 64)
		wei.Once_Burn, _ =strconv.ParseFloat(fmt.Sprintf("%.3f", 0.203*float64(num.Once_Burn)), 64)
		wei.Once_Burn_Furnace, _ =strconv.ParseFloat(fmt.Sprintf("%.2f", 0.22*float64(num.Once_Burn_Furnace)), 64)
		wei.Green_Body, _ =strconv.ParseFloat(fmt.Sprintf("%.2f", 0.22*float64(num.Green_Body)), 64)
	case "IP(黄点)":
		wei.Finish_Product = float64(num.Finish_Product)
		wei.RoughCast, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", 0.22*float64(num.RoughCast)), 64)
		wei.Graphitization_Furnace, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.227*float64(num.Graphitization_Furnace)), 64)
		wei.Forth_Burn, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.227*float64(num.Forth_Burn)), 64)
		wei.Third_Dip, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", 0.24*float64(num.Third_Dip)), 64)
		wei.Third_Burn, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.218*float64(num.Third_Burn)), 64)
		wei.Second_Dip, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.231*float64(num.Second_Dip)), 64)
		wei.Second_Burn, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.209*float64(num.Once_Burn_Furnace)), 64)
		wei.Second_Burn_Furnace, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", 0.23*float64(num.Second_Burn_Furnace)), 64)
		wei.Once_Dip, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", 0.23*float64(num.Once_Dip)), 64)
		wei.Once_Burn, _ =strconv.ParseFloat(fmt.Sprintf("%.3f", 0.203*float64(num.Once_Burn)), 64)
		wei.Once_Burn_Furnace, _ =strconv.ParseFloat(fmt.Sprintf("%.2f", 0.22*float64(num.Once_Burn_Furnace)), 64)
		wei.Green_Body, _ =strconv.ParseFloat(fmt.Sprintf("%.2f", 0.22*float64(num.Green_Body)), 64)
	case "IP(红点)":
		wei.Finish_Product = float64(num.Finish_Product)
		wei.RoughCast, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", 0.22*float64(num.RoughCast)), 64)
		wei.Graphitization_Furnace, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.227*float64(num.Graphitization_Furnace)), 64)
		wei.Forth_Burn, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.227*float64(num.Forth_Burn)), 64)
		wei.Third_Dip, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", 0.24*float64(num.Third_Dip)), 64)
		wei.Third_Burn, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.218*float64(num.Third_Burn)), 64)
		wei.Second_Dip, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.231*float64(num.Second_Dip)), 64)
		wei.Second_Burn, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.209*float64(num.Once_Burn_Furnace)), 64)
		wei.Second_Burn_Furnace, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", 0.23*float64(num.Second_Burn_Furnace)), 64)
		wei.Once_Dip, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", 0.23*float64(num.Once_Dip)), 64)
		wei.Once_Burn, _ =strconv.ParseFloat(fmt.Sprintf("%.3f", 0.203*float64(num.Once_Burn)), 64)
		wei.Once_Burn_Furnace, _ =strconv.ParseFloat(fmt.Sprintf("%.2f", 0.22*float64(num.Once_Burn_Furnace)), 64)
		wei.Green_Body, _ =strconv.ParseFloat(fmt.Sprintf("%.2f", 0.22*float64(num.Green_Body)), 64)
	}
	_,err := collection.UpdateOne(context.Background(), bson.M{"time_stamp":wei.Time_Stamp},bson.M{"$set": wei})
	if err != nil {
		fmt.Println(err)
	}

	//同步汇总表
	parts := strings.SplitN(wei.Process_Length, "(", 2)
	var cargo model.CargoSummary
	var tmp = wei.Diameter + parts[0]
	CargoSummary := db.Collection("CargoSummary")
	err = CargoSummary.FindOne(context.Background(), bson.M{"process_specifications": tmp}).Decode(&cargo)
	if err!= nil {
		log.Println(err)
	} else {
		cargo.Finish_Product,_ = strconv.ParseFloat(fmt.Sprintf("%.1f",wei.Finish_Product ), 64)
		cargo.RoughCast,_ = strconv.ParseFloat(fmt.Sprintf("%.1f",wei.RoughCast ), 64)
		cargo.Second_Burn,_ = strconv.ParseFloat(fmt.Sprintf("%.1f",wei.Second_Burn + wei.Second_Burn_Furnace ), 64)
		cargo.Once_Dip,_ =strconv.ParseFloat(fmt.Sprintf("%.1f",wei.Once_Dip ), 64)
		cargo.Once_Burn,_ = strconv.ParseFloat(fmt.Sprintf("%.1f",wei.Once_Burn), 64)
		cargo.Green_Body,_ = strconv.ParseFloat(fmt.Sprintf("%.1f", wei.Once_Burn_Furnace + wei.Green_Body), 64)
		cargo.Time_Stamp = wei.Time_Stamp
		cargo.Diameter = wei.Diameter

		util.UpdateOne1(c,"CargoSummary",cargo,"_id",cargo.Id)
	}
	return wei
}
//直径315
func UpdateWeight315(c *gin.Context,num model.Amount,col string) interface{}{
	db := database.GetMongoDB()
	collection := db.Collection(col)
	var wei model.Weight
	wei.Diameter = num.Diameter
	wei.Desc = num.Desc
	wei.Process_Length = num.Process_Length
	wei.Time_Stamp = num.Time_Stamp
	switch num.Process_Length {
	case "IP(白点)":
		wei.Finish_Product = float64(num.Finish_Product)
		wei.RoughCast, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.272*float64(num.RoughCast)), 64)
		wei.Graphitization_Furnace, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", 0.28*float64(num.Graphitization_Furnace)), 64)
		wei.Forth_Burn, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", 0.28*float64(num.Forth_Burn)), 64)
		wei.Third_Dip, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", 0.3*float64(num.Third_Dip)), 64)
		wei.Third_Burn, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.279*float64(num.Third_Burn)), 64)
		wei.Second_Dip, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.297*float64(num.Second_Dip)), 64)
		wei.Second_Burn, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.275*float64(num.Once_Burn_Furnace)), 64)
		wei.Second_Burn_Furnace, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.295*float64(num.Second_Burn_Furnace)), 64)
		wei.Once_Dip, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.295*float64(num.Once_Dip)), 64)
		wei.Once_Burn, _ =strconv.ParseFloat(fmt.Sprintf("%.3f", 0.254*float64(num.Once_Burn)), 64)
		wei.Once_Burn_Furnace, _ =strconv.ParseFloat(fmt.Sprintf("%.3f", 0.277*float64(num.Once_Burn_Furnace)), 64)
		wei.Green_Body, _ =strconv.ParseFloat(fmt.Sprintf("%.3f", 0.277*float64(num.Green_Body)), 64)
	case "IP(黄点)":
		wei.Finish_Product = float64(num.Finish_Product)
		wei.RoughCast, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.275*float64(num.RoughCast)), 64)
		wei.Graphitization_Furnace, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.285*float64(num.Graphitization_Furnace)), 64)
		wei.Forth_Burn, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.285*float64(num.Forth_Burn)), 64)
		wei.Third_Dip, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.303*float64(num.Third_Dip)), 64)
		wei.Third_Burn, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.282*float64(num.Third_Burn)), 64)
		wei.Second_Dip, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", 0.3*float64(num.Second_Dip)), 64)
		wei.Second_Burn, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.277*float64(num.Once_Burn_Furnace)), 64)
		wei.Second_Burn_Furnace, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.297*float64(num.Second_Burn_Furnace)), 64)
		wei.Once_Dip, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.297*float64(num.Once_Dip)), 64)
		wei.Once_Burn, _ =strconv.ParseFloat(fmt.Sprintf("%.3f", 0.256*float64(num.Once_Burn)), 64)
		wei.Once_Burn_Furnace, _ =strconv.ParseFloat(fmt.Sprintf("%.3f", 0.277*float64(num.Once_Burn_Furnace)), 64)
		wei.Green_Body, _ =strconv.ParseFloat(fmt.Sprintf("%.3f", 0.277*float64(num.Green_Body)), 64)
	case "IP(红点)":
		wei.Finish_Product = float64(num.Finish_Product)
		wei.RoughCast, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.277*float64(num.RoughCast)), 64)
		wei.Graphitization_Furnace, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.277*float64(num.Graphitization_Furnace)), 64)
		wei.Forth_Burn, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.287*float64(num.Forth_Burn)), 64)
		wei.Third_Dip, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.305*float64(num.Third_Dip)), 64)
		wei.Third_Burn, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.284*float64(num.Third_Burn)), 64)
		wei.Second_Dip, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.302*float64(num.Second_Dip)), 64)
		wei.Second_Burn, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", 0.28*float64(num.Once_Burn_Furnace)), 64)
		wei.Second_Burn_Furnace, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", 0.3*float64(num.Second_Burn_Furnace)), 64)
		wei.Once_Dip, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", 0.3*float64(num.Once_Dip)), 64)
		wei.Once_Burn, _ =strconv.ParseFloat(fmt.Sprintf("%.3f", 0.254*float64(num.Once_Burn)), 64)
		wei.Once_Burn_Furnace, _ =strconv.ParseFloat(fmt.Sprintf("%.3f", 0.275*float64(num.Once_Burn_Furnace)), 64)
		wei.Green_Body, _ =strconv.ParseFloat(fmt.Sprintf("%.3f", 0.275*float64(num.Green_Body)), 64)
	}
	_,err := collection.UpdateOne(context.Background(), bson.M{"time_stamp":wei.Time_Stamp},bson.M{"$set": wei})
	if err != nil {
		fmt.Println(err)
	}

	//同步汇总表
	parts := strings.SplitN(wei.Process_Length, "(", 2)
	var cargo model.CargoSummary
	var tmp = wei.Diameter + parts[0]
	CargoSummary := db.Collection("CargoSummary")
	err = CargoSummary.FindOne(context.Background(), bson.M{"process_specifications": tmp}).Decode(&cargo)
	if err!= nil {
		log.Println(err)
	} else {
		cargo.Finish_Product,_ = strconv.ParseFloat(fmt.Sprintf("%.1f",wei.Finish_Product ), 64)
		cargo.RoughCast,_ = strconv.ParseFloat(fmt.Sprintf("%.1f",wei.RoughCast ), 64)
		cargo.Second_Burn,_ = strconv.ParseFloat(fmt.Sprintf("%.1f",wei.Second_Burn + wei.Second_Burn_Furnace ), 64)
		cargo.Once_Dip,_ =strconv.ParseFloat(fmt.Sprintf("%.1f",wei.Once_Dip ), 64)
		cargo.Once_Burn,_ = strconv.ParseFloat(fmt.Sprintf("%.1f",wei.Once_Burn), 64)
		cargo.Green_Body,_ = strconv.ParseFloat(fmt.Sprintf("%.1f", wei.Once_Burn_Furnace + wei.Green_Body), 64)
		cargo.Time_Stamp = wei.Time_Stamp
		cargo.Diameter = wei.Diameter

		util.UpdateOne1(c,"CargoSummary",cargo,"_id",cargo.Id)
	}
	return wei
}
//直径333
func UpdateWeight333(c *gin.Context,num model.Amount,col string) interface{}{
	db := database.GetMongoDB()
	collection := db.Collection(col)
	var wei model.Weight
	wei.Diameter = num.Diameter
	wei.Desc = num.Desc
	wei.Process_Length = num.Process_Length
	wei.Time_Stamp = num.Time_Stamp
	switch num.Process_Length {
	case "IP(白点)":
		wei.Finish_Product = float64(num.Finish_Product)
		wei.RoughCast, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", 0.3*float64(num.RoughCast)), 64)
		wei.Graphitization_Furnace, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.305*float64(num.Graphitization_Furnace)), 64)
		wei.Forth_Burn, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.305*float64(num.Forth_Burn)), 64)
		wei.Third_Dip, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.333*float64(num.Third_Dip)), 64)
		wei.Third_Burn, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.302*float64(num.Third_Burn)), 64)
		wei.Second_Dip, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.325*float64(num.Second_Dip)), 64)
		wei.Second_Burn, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.294*float64(num.Once_Burn_Furnace)), 64)
		wei.Second_Burn_Furnace, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.319*float64(num.Second_Burn_Furnace)), 64)
		wei.Once_Dip, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.319*float64(num.Once_Dip)), 64)
		wei.Once_Burn, _ =strconv.ParseFloat(fmt.Sprintf("%.3f", 0.278*float64(num.Once_Burn)), 64)
		wei.Once_Burn_Furnace, _ =strconv.ParseFloat(fmt.Sprintf("%.3f", 0.306*float64(num.Once_Burn_Furnace)), 64)
		wei.Green_Body, _ =strconv.ParseFloat(fmt.Sprintf("%.3f", 0.306*float64(num.Green_Body)), 64)
	case "IP(黄点)":
		wei.Finish_Product = float64(num.Finish_Product)
		wei.RoughCast, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", 0.3*float64(num.RoughCast)), 64)
		wei.Graphitization_Furnace, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.305*float64(num.Graphitization_Furnace)), 64)
		wei.Forth_Burn, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.305*float64(num.Forth_Burn)), 64)
		wei.Third_Dip, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", 0.32*float64(num.Third_Dip)), 64)
		wei.Third_Burn, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", 0.31*float64(num.Third_Burn)), 64)
		wei.Second_Dip, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.325*float64(num.Second_Dip)), 64)
		wei.Second_Burn, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.294*float64(num.Once_Burn_Furnace)), 64)
		wei.Second_Burn_Furnace, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.319*float64(num.Second_Burn_Furnace)), 64)
		wei.Once_Dip, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.319*float64(num.Once_Dip)), 64)
		wei.Once_Burn, _ =strconv.ParseFloat(fmt.Sprintf("%.3f", 0.278*float64(num.Once_Burn)), 64)
		wei.Once_Burn_Furnace, _ =strconv.ParseFloat(fmt.Sprintf("%.3f", 0.306*float64(num.Once_Burn_Furnace)), 64)
		wei.Green_Body, _ =strconv.ParseFloat(fmt.Sprintf("%.3f", 0.306*float64(num.Green_Body)), 64)
	case "IP(红点)":
		wei.Finish_Product = float64(num.Finish_Product)
		wei.RoughCast, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", 0.3*float64(num.RoughCast)), 64)
		wei.Graphitization_Furnace, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.305*float64(num.Graphitization_Furnace)), 64)
		wei.Forth_Burn, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.305*float64(num.Forth_Burn)), 64)
		wei.Third_Dip, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", 0.31*float64(num.Third_Dip)), 64)
		wei.Third_Burn, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.302*float64(num.Third_Burn)), 64)
		wei.Second_Dip, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.325*float64(num.Second_Dip)), 64)
		wei.Second_Burn, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.294*float64(num.Once_Burn_Furnace)), 64)
		wei.Second_Burn_Furnace, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.319*float64(num.Second_Burn_Furnace)), 64)
		wei.Once_Dip, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.319*float64(num.Once_Dip)), 64)
		wei.Once_Burn, _ =strconv.ParseFloat(fmt.Sprintf("%.3f", 0.278*float64(num.Once_Burn)), 64)
		wei.Once_Burn_Furnace, _ =strconv.ParseFloat(fmt.Sprintf("%.3f", 0.306*float64(num.Once_Burn_Furnace)), 64)
		wei.Green_Body, _ =strconv.ParseFloat(fmt.Sprintf("%.3f", 0.306*float64(num.Green_Body)), 64)
	}
	_,err := collection.UpdateOne(context.Background(), bson.M{"time_stamp":wei.Time_Stamp},bson.M{"$set": wei})
	if err != nil {
		fmt.Println(err)
	}

	//同步汇总表
	parts := strings.SplitN(wei.Process_Length, "(", 2)
	var cargo model.CargoSummary
	var tmp = wei.Diameter + parts[0]
	CargoSummary := db.Collection("CargoSummary")
	err = CargoSummary.FindOne(context.Background(), bson.M{"process_specifications": tmp}).Decode(&cargo)
	if err!= nil {
		log.Println(err)
	} else {
		cargo.Finish_Product,_ = strconv.ParseFloat(fmt.Sprintf("%.1f",wei.Finish_Product ), 64)
		cargo.RoughCast,_ = strconv.ParseFloat(fmt.Sprintf("%.1f",wei.RoughCast ), 64)
		cargo.Second_Burn,_ = strconv.ParseFloat(fmt.Sprintf("%.1f",wei.Second_Burn + wei.Second_Burn_Furnace ), 64)
		cargo.Once_Dip,_ =strconv.ParseFloat(fmt.Sprintf("%.1f",wei.Once_Dip ), 64)
		cargo.Once_Burn,_ = strconv.ParseFloat(fmt.Sprintf("%.1f",wei.Once_Burn), 64)
		cargo.Green_Body,_ = strconv.ParseFloat(fmt.Sprintf("%.1f", wei.Once_Burn_Furnace + wei.Green_Body), 64)
		cargo.Time_Stamp = wei.Time_Stamp
		cargo.Diameter = wei.Diameter
		util.UpdateOne1(c,"CargoSummary",cargo,"_id",cargo.Id)
	}
	return wei
}
//直径次品
func UpdateLow(c *gin.Context,num model.Amount,col string) interface{}{
	db := database.GetMongoDB()
	collection := db.Collection(col)
	var wei model.Weight
	wei.Diameter = num.Diameter
	wei.Desc = num.Desc
	wei.Process_Length = num.Process_Length
	wei.Time_Stamp = num.Time_Stamp
	switch num.Process_Length {
	case "Φ600":
		wei.Finish_Product , _= strconv.ParseFloat(fmt.Sprintf("%.2f", 1.02*float64(num.Finish_Product)), 64)
		wei.RoughCast, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 1.167*float64(num.RoughCast)), 64)
		wei.Forth_Burn= float64(num.Forth_Burn)
		wei.Third_Burn=float64(num.Third_Burn)
		wei.Second_Burn, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 1.225*float64(num.Once_Burn_Furnace)), 64)
		wei.Once_Dip, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 1.322*float64(num.Once_Dip)), 64)
		wei.Once_Burn, _ =strconv.ParseFloat(fmt.Sprintf("%.3f", 1.144*float64(num.Once_Burn)), 64)
		wei.Green_Body, _ =strconv.ParseFloat(fmt.Sprintf("%.3f", 1.229*float64(num.Green_Body)), 64)
	case "Φ550":
		wei.Finish_Product , _= strconv.ParseFloat(fmt.Sprintf("%.3f", 0.876*float64(num.Finish_Product)), 64)
		wei.RoughCast, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.976*float64(num.RoughCast)), 64)
		wei.Forth_Burn= float64(num.Forth_Burn)
		wei.Third_Burn=float64(num.Third_Burn)
		wei.Second_Burn, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 1.005*float64(num.Once_Burn_Furnace)), 64)
		wei.Once_Dip, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 1.087*float64(num.Once_Dip)), 64)
		wei.Once_Burn, _ =strconv.ParseFloat(fmt.Sprintf("%.3f", 0.943*float64(num.Once_Burn)), 64)
		wei.Green_Body, _ =strconv.ParseFloat(fmt.Sprintf("%.3f", 1.022*float64(num.Green_Body)), 64)
	case "Φ500":
		wei.Finish_Product , _= strconv.ParseFloat(fmt.Sprintf("%.2f", 0.65*float64(num.Finish_Product)), 64)
		wei.RoughCast, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.805*float64(num.RoughCast)), 64)
		wei.Forth_Burn= float64(num.Forth_Burn)
		wei.Third_Burn=float64(num.Third_Burn)
		wei.Second_Burn, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.828*float64(num.Once_Burn_Furnace)), 64)
		wei.Once_Dip, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.898*float64(num.Once_Dip)), 64)
		wei.Once_Burn, _ =strconv.ParseFloat(fmt.Sprintf("%.2f", 0.78*float64(num.Once_Burn)), 64)
		wei.Green_Body, _ =strconv.ParseFloat(fmt.Sprintf("%.3f",0.845*float64(num.Green_Body)), 64)
	case "Φ450":
		wei.Finish_Product , _= strconv.ParseFloat(fmt.Sprintf("%.2f", 0.53*float64(num.Finish_Product)), 64)
		wei.RoughCast, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.618*float64(num.RoughCast)), 64)
		wei.Forth_Burn= float64(num.Forth_Burn)
		wei.Third_Burn=float64(num.Third_Burn)
		wei.Second_Burn, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.664*float64(num.Once_Burn_Furnace)), 64)
		wei.Once_Dip, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.721*float64(num.Once_Dip)), 64)
		wei.Once_Burn, _ =strconv.ParseFloat(fmt.Sprintf("%.2f", 0.63*float64(num.Once_Burn)), 64)
		wei.Green_Body, _ =strconv.ParseFloat(fmt.Sprintf("%.3f", 0.685*float64(num.Green_Body)), 64)
	case "Φ400":
		wei.Finish_Product , _= strconv.ParseFloat(fmt.Sprintf("%.2f", 0.39*float64(num.Finish_Product)), 64)
		wei.RoughCast, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.465*float64(num.RoughCast)), 64)
		wei.Forth_Burn= float64(num.Forth_Burn)
		wei.Third_Burn=float64(num.Third_Burn)
		wei.Second_Burn, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.497*float64(num.Once_Burn_Furnace)), 64)
		wei.Once_Dip, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.536*float64(num.Once_Dip)), 64)
		wei.Once_Burn, _ =strconv.ParseFloat(fmt.Sprintf("%.2f", 0.46*float64(num.Once_Burn)), 64)
		wei.Green_Body, _ =strconv.ParseFloat(fmt.Sprintf("%.3f", 0.497*float64(num.Green_Body)), 64)
	case "Φ350":
		wei.Finish_Product , _= strconv.ParseFloat(fmt.Sprintf("%.2f", 0.3*float64(num.Finish_Product)), 64)
		wei.RoughCast, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.36*float64(num.RoughCast)), 64)
		wei.Forth_Burn= float64(num.Forth_Burn)
		wei.Third_Burn=float64(num.Third_Burn)
		wei.Second_Burn, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.386*float64(num.Once_Burn_Furnace)), 64)
		wei.Once_Dip, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.418*float64(num.Once_Dip)), 64)
		wei.Once_Burn, _ =strconv.ParseFloat(fmt.Sprintf("%.3f", 0.35*float64(num.Once_Burn)), 64)
		wei.Green_Body, _ =strconv.ParseFloat(fmt.Sprintf("%.3f", 0.383*float64(num.Green_Body)), 64)
	case "Φ300":
		wei.Finish_Product , _= strconv.ParseFloat(fmt.Sprintf("%.2f", 0.26*float64(num.Finish_Product)), 64)
		wei.RoughCast, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.268*float64(num.RoughCast)), 64)
		wei.Forth_Burn= float64(num.Forth_Burn)
		wei.Third_Burn=float64(num.Third_Burn)
		wei.Second_Burn, _ = strconv.ParseFloat(fmt.Sprintf("%.3f",0.288*float64(num.Once_Burn_Furnace)), 64)
		wei.Once_Dip, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.312*float64(num.Once_Dip)), 64)
		wei.Once_Burn, _ =strconv.ParseFloat(fmt.Sprintf("%.2f", 0.27*float64(num.Once_Burn)), 64)
		wei.Green_Body, _ =strconv.ParseFloat(fmt.Sprintf("%.3f", 0.292*float64(num.Green_Body)), 64)
	case "Φ250":
		wei.Finish_Product= float64(num.Finish_Product)
		wei.RoughCast, _ = strconv.ParseFloat(fmt.Sprintf("%.3f",0.185*float64(num.RoughCast)), 64)
		wei.Forth_Burn= float64(num.Forth_Burn)
		wei.Third_Burn=float64(num.Third_Burn)
		wei.Second_Burn, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.188*float64(num.Once_Burn_Furnace)), 64)
		wei.Once_Dip, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.192*float64(num.Once_Dip)), 64)
		wei.Once_Burn, _ =strconv.ParseFloat(fmt.Sprintf("%.3f", 0.179*float64(num.Once_Burn)), 64)
		wei.Green_Body, _ =strconv.ParseFloat(fmt.Sprintf("%.3f", 0.194*float64(num.Green_Body)), 64)
	case "Φ200":
		wei.Finish_Product , _= strconv.ParseFloat(fmt.Sprintf("%.2f", 0.1*float64(num.Finish_Product)), 64)
		wei.RoughCast, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.112*float64(num.RoughCast)), 64)
		wei.Forth_Burn= float64(num.Forth_Burn)
		wei.Third_Burn=float64(num.Third_Burn)
		wei.Second_Burn=float64(num.Once_Burn_Furnace)
		wei.Once_Dip= float64(num.Once_Dip)
		wei.Once_Burn, _ =strconv.ParseFloat(fmt.Sprintf("%.3f", 0.114*float64(num.Once_Burn)), 64)
		wei.Green_Body, _ =strconv.ParseFloat(fmt.Sprintf("%.3f", 0.123*float64(num.Green_Body)), 64)
	case "Φ234":
		wei.Finish_Product=float64(num.Finish_Product)
		wei.RoughCast, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", 0.15*float64(num.RoughCast)), 64)
		wei.Forth_Burn, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.155*float64(num.Forth_Burn)), 64)
		wei.Third_Burn, _ =strconv.ParseFloat(fmt.Sprintf("%.3f", 0.151*float64(num.Third_Burn)), 64)
		wei.Second_Burn, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", 0.15*float64(num.Once_Burn_Furnace)), 64)
		wei.Once_Dip, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.159*float64(num.Once_Dip)), 64)
		wei.Once_Burn, _ =strconv.ParseFloat(fmt.Sprintf("%.3f", 0.141*float64(num.Once_Burn)), 64)
		wei.Green_Body, _ =strconv.ParseFloat(fmt.Sprintf("%.3f", 0.152*float64(num.Green_Body)), 64)
	case "Φ256":
		wei.Finish_Product=float64(num.Finish_Product)
		wei.RoughCast, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.172*float64(num.RoughCast)), 64)
		wei.Forth_Burn, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.183*float64(num.Forth_Burn)), 64)
		wei.Third_Burn, _ =strconv.ParseFloat(fmt.Sprintf("%.3f", 0.176*float64(num.Third_Burn)), 64)
		wei.Second_Burn, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.163*float64(num.Once_Burn_Furnace)), 64)
		wei.Once_Dip, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.189*float64(num.Once_Dip)), 64)
		wei.Once_Burn, _ =strconv.ParseFloat(fmt.Sprintf("%.2f", 0.13*float64(num.Once_Burn)), 64)
		wei.Green_Body, _ =strconv.ParseFloat(fmt.Sprintf("%.3f", 0.173*float64(num.Green_Body)), 64)
	case "Φ288":
		wei.Finish_Product=float64(num.Finish_Product)
		wei.RoughCast, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", 0.22*float64(num.RoughCast)), 64)
		wei.Forth_Burn, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.227*float64(num.Forth_Burn)), 64)
		wei.Third_Burn, _ =strconv.ParseFloat(fmt.Sprintf("%.3f", 0.218*float64(num.Third_Burn)), 64)
		wei.Second_Burn, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", 0.209*float64(num.Once_Burn_Furnace)), 64)
		wei.Once_Dip, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", 0.23*float64(num.Once_Dip)), 64)
		wei.Once_Burn, _ =strconv.ParseFloat(fmt.Sprintf("%.3f", 0.203*float64(num.Once_Burn)), 64)
		wei.Green_Body, _ =strconv.ParseFloat(fmt.Sprintf("%.2f", 0.22*float64(num.Green_Body)), 64)
	case "Φ315":
		wei.Finish_Product=float64(num.Finish_Product)
		wei.RoughCast, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.277*float64(num.RoughCast)), 64)
		wei.Forth_Burn, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.287*float64(num.Forth_Burn)), 64)
		wei.Third_Burn, _ =strconv.ParseFloat(fmt.Sprintf("%.3f", 0.284*float64(num.Third_Burn)), 64)
		wei.Second_Burn, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", 0.28*float64(num.Once_Burn_Furnace)), 64)
		wei.Once_Dip, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", 0.3*float64(num.Once_Dip)), 64)
		wei.Once_Burn, _ =strconv.ParseFloat(fmt.Sprintf("%.3f", 0.254*float64(num.Once_Burn)), 64)
		wei.Green_Body, _ =strconv.ParseFloat(fmt.Sprintf("%.3f", 0.275*float64(num.Green_Body)), 64)
	case "Φ333":
		wei.Finish_Product=float64(num.Finish_Product)
		wei.RoughCast, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", 0.3*float64(num.RoughCast)), 64)
		wei.Forth_Burn, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.305*float64(num.Forth_Burn)), 64)
		wei.Third_Burn, _ =strconv.ParseFloat(fmt.Sprintf("%.2f", 0.31*float64(num.Third_Burn)), 64)
		wei.Second_Burn, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.294*float64(num.Once_Burn_Furnace)), 64)
		wei.Once_Dip, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.319*float64(num.Once_Dip)), 64)
		wei.Once_Burn, _ =strconv.ParseFloat(fmt.Sprintf("%.3f", 0.278*float64(num.Once_Burn)), 64)
		wei.Green_Body, _ =strconv.ParseFloat(fmt.Sprintf("%.3f", 0.306*float64(num.Green_Body)), 64)
	}
	_,err := collection.UpdateOne(context.Background(), bson.M{"time_stamp":wei.Time_Stamp},bson.M{"$set": wei})
	if err != nil {
		fmt.Println(err)
	}

	return wei
}

func UploadImg(c *gin.Context,file multipart.File, header *multipart.FileHeader)  {
	filename := header.Filename
	out, err := os.Create("/www/wwwroot/files/image/personal/"+filename)
	if err != nil {
		log.Println("创建文件:",err)
	}
	defer out.Close()

	_, err = io.Copy(out, file)
	if err != nil {
		log.Println("更新文件:",err)
	}
	filepath := "http://82.156.109.119/files/image/personal/" + filename
	util.Return(c,200,util.SUCCESS,filepath)
}